package p_400

import com.sun.xml.internal.fastinfoset.util.StringArray
import java.net.DatagramPacket
import java.net.DatagramSocket

/**
 * TCP echo 服务
 */
class UDPEchoSever(port: Int = 7) : UdpServer(port) {

    companion object {
        fun main(args: StringArray) {
            val server = UDPEchoSever()
            Thread(server).apply { start() }
        }
    }

    override fun response(socket: DatagramSocket, com: DatagramPacket) {
        val outGoing = DatagramPacket(com.data, com.length, com.address, com.port)
        socket.send(outGoing)
    }

}